package com.sun.lib;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.RadioGroup;

import com.sun.lib.helper.SGroupHelper;

public class SRadioGroup extends RadioGroup implements SHelper<SGroupHelper<RadioGroup>> {
    private SGroupHelper<RadioGroup> mHelper;
    public SRadioGroup(Context context) {
        this(context,null);
    }

    public SRadioGroup(Context context, AttributeSet attrs) {
        super(context, attrs);
        mHelper = new SGroupHelper<>(context,this,attrs);
    }

    @Override
    public SGroupHelper<RadioGroup> getHelper() {
        return mHelper;
    }

    @Override
    public void setCornerRadius(float radius) {
        mHelper.setmCornerRadius(radius);
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
        mHelper.onLayout(changed, l, t, r, b);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        mHelper.onDraw(canvas);
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        mHelper.dispatchDrawBefore(canvas);
        super.dispatchDraw(canvas);
        mHelper.dispatchDrawAfter(canvas);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        if (mHelper != null)
            mHelper.onSizeChanged(w, h, oldw, oldh);
    }
}
